<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    Less.md |  Small Bridge
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/css/main.css">

  
  <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  
  

  

<link rel="alternate" href="/atom.xml" title="Small Bridge" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      <section class="outer">
  <article id="post-Less-md" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Less.md
</h1>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/05/14/Less-md/" class="article-date">
  <time datetime="2020-05-14T13:28:10.000Z" itemprop="datePublished">2020-05-14</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/CSS/">CSS</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">2.1k字</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">10分钟</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      


      

      
      <p>@<a href="Less">TOC</a></p>
<h1 id="为什么要使用Less"><a href="#为什么要使用Less" class="headerlink" title="为什么要使用Less"></a>为什么要使用Less</h1><a id="more"></a>
<p>你是否对一成不变的CSS书写感到厌烦？你是否对多次书写同样的内容感到不满？你会思考，为什么CSS中不能像其他语言一样书写变量，封装函数进行代码的复用，很明显，原生CSS并不具备这个功能，但是，我们可以使用CSS预处理器，Less便是其中的一种，类似的还有Sass和Stylus</p>
<h1 id="什么是预处理器"><a href="#什么是预处理器" class="headerlink" title="什么是预处理器"></a>什么是预处理器</h1><p>CSS 预处理器定义了一种新的语言，其基本思想是，用一种专门的编程语言，为 CSS 增加了一些编程的特性，将 CSS 作为目标生成文件，然后开发者就只要使用这种语言进行编码工作。</p>
<p>通俗的说，“CSS 预处理器用一种专门的编程语言，进行 Web 页面样式设计，然后再编译成正常的 CSS 文件，以供项目使用。CSS 预处理器为 CSS 增加一些编程的特性，无需考虑浏览器的兼容性问题”，例如你可以在 CSS 中使用变量、简单的逻辑程序、函数等等<br>下面我们就开始Less的介绍吧</p>
<h1 id="Less注释"><a href="#Less注释" class="headerlink" title="Less注释"></a>Less注释</h1><p>在Less文件中以//开头的注释不会被编译到CSS文件中，但是以/**/包裹的注释会，大家可以利用这一点实现注释的可观看性</p>
<h1 id="Less变量"><a href="#Less变量" class="headerlink" title="Less变量"></a>Less变量</h1><p>在Less中使用@符号来声明一个变量，比如@pink：pink，但是需要注意：<br>less变量是块级作用域(就是一对{}内部有效)<br>变量作为普通值来使用，直接使用@pink<br>作为选择器或者属性名来使用，使用@{值}的形式<br>作为URL来使用，同样是@{URL}的形式<br>变量是延迟加载的</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			/* 定义变量使用@符号 */</span></span><br><span class="line"><span class="string">			@color:pink;</span></span><br><span class="line"><span class="string">			#wrap &#123;</span></span><br><span class="line"><span class="string">				position: relative;</span></span><br><span class="line"><span class="string">				width: 300px;</span></span><br><span class="line"><span class="string">				height: 400px;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				margin: 0 auto;</span></span><br><span class="line"><span class="string">				.inner &#123;</span></span><br><span class="line"><span class="string">					position: absolute;</span></span><br><span class="line"><span class="string">					top: 0;</span></span><br><span class="line"><span class="string">					right: 0;</span></span><br><span class="line"><span class="string">					bottom: 0;</span></span><br><span class="line"><span class="string">					left: 0;</span></span><br><span class="line"><span class="string">					margin: auto;</span></span><br><span class="line"><span class="string">					background: @color;</span></span><br><span class="line"><span class="string">					height: 100px;</span></span><br><span class="line"><span class="string">					width: 100px;</span></span><br><span class="line"><span class="string">				   &#125;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">@<span class="keyword">var</span>: <span class="number">0</span>;</span><br><span class="line">.class&#123;</span><br><span class="line">@<span class="keyword">var</span>: <span class="number">1</span>;</span><br><span class="line">	.brass&#123;</span><br><span class="line">		@<span class="keyword">var</span>: <span class="number">2</span>;</span><br><span class="line">		three: @<span class="keyword">var</span>; <span class="comment">//3</span></span><br><span class="line">		@<span class="keyword">var</span>: <span class="number">3</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	one: @<span class="keyword">var</span>;   <span class="comment">//1</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">//因为less变量都是延迟加载的，它会等brass里面的所有东西都编译完了，再来解析@var变量</span></span><br><span class="line"><span class="comment">//所以此时的值应该为3</span></span><br></pre></td></tr></table></figure>
<h1 id="Less的嵌套规则"><a href="#Less的嵌套规则" class="headerlink" title="Less的嵌套规则"></a>Less的嵌套规则</h1><p>使用空格区分父子级，使用&amp;字符表示平级</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			/* 定义变量使用@符号 */</span></span><br><span class="line"><span class="string">			@color:pink;</span></span><br><span class="line"><span class="string">			#wrap &#123;</span></span><br><span class="line"><span class="string">				position: relative;</span></span><br><span class="line"><span class="string">				width: 300px;</span></span><br><span class="line"><span class="string">				height: 400px;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				margin: 0 auto;</span></span><br><span class="line"><span class="string">				.inner &#123;</span></span><br><span class="line"><span class="string">					position: absolute;</span></span><br><span class="line"><span class="string">					top: 0;</span></span><br><span class="line"><span class="string">					right: 0;</span></span><br><span class="line"><span class="string">					bottom: 0;</span></span><br><span class="line"><span class="string">					left: 0;</span></span><br><span class="line"><span class="string">					margin: auto;</span></span><br><span class="line"><span class="string">					background: @color;</span></span><br><span class="line"><span class="string">					height: 100px;</span></span><br><span class="line"><span class="string">					width: 100px;</span></span><br><span class="line"><span class="string">					/* &amp;表示 #wrap .inner */</span></span><br><span class="line"><span class="string">					&amp;:hover&#123;</span></span><br><span class="line"><span class="string">						background: deeppink;</span></span><br><span class="line"><span class="string">					&#125;</span></span><br><span class="line"><span class="string">				   &#125;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<h1 id="Less混合"><a href="#Less混合" class="headerlink" title="Less混合"></a>Less混合</h1><p>混合就是将一系列属性从一个规则集引入到另一个规则集的方式，less中混合使用.(点)定义,混合分为以下几种：<br>普通混合<br>不带输出的混合<br>带参数的混合<br>带默认值和参数的混合<br>带多个参数的混合<br>命名参数<br>匹配模式(根据传入参数的不同实现不同的功能)</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			/* 定义一个混合 */</span></span><br><span class="line"><span class="string">			/* 这是普通混合的定义方式，编译成css后将会在文件中输出 */</span></span><br><span class="line"><span class="string">			/* 不带输出的混合定义方式需要加个括号  .juzhong() */</span></span><br><span class="line"><span class="string">			/* .juzhong&#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				background: gray;</span></span><br><span class="line"><span class="string">				height: 100px;</span></span><br><span class="line"><span class="string">				width: 100px;</span></span><br><span class="line"><span class="string">			&#125; */</span></span><br><span class="line"><span class="string">			/* 带参数的混合 */</span></span><br><span class="line"><span class="string">			/* 参数可以有默认值 */</span></span><br><span class="line"><span class="string">			.juzhong(@w:10px,@h:10px,@c:pink)&#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				background: @c;</span></span><br><span class="line"><span class="string">				height: @h;</span></span><br><span class="line"><span class="string">				width: @w;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			#wrap &#123;</span></span><br><span class="line"><span class="string">				position: relative;</span></span><br><span class="line"><span class="string">				width: 300px;</span></span><br><span class="line"><span class="string">				height: 400px;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				margin: 0 auto;</span></span><br><span class="line"><span class="string">				.inner &#123;</span></span><br><span class="line"><span class="string">					.juzhong(100px,100px,pink);</span></span><br><span class="line"><span class="string">					&amp;:hover&#123;</span></span><br><span class="line"><span class="string">						background: deeppink;</span></span><br><span class="line"><span class="string">					&#125;</span></span><br><span class="line"><span class="string">				   &#125; </span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>../less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			.juzhong(@w:10px,@h:10px,@c:pink)&#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				background: @c;</span></span><br><span class="line"><span class="string">				height: @h;</span></span><br><span class="line"><span class="string">				width: @w;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			#wrap &#123;</span></span><br><span class="line"><span class="string">				position: relative;</span></span><br><span class="line"><span class="string">				width: 300px;</span></span><br><span class="line"><span class="string">				height: 400px;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				margin: 0 auto;</span></span><br><span class="line"><span class="string">				.inner &#123;</span></span><br><span class="line"><span class="string">					/* 命名参数 */</span></span><br><span class="line"><span class="string">					.juzhong(@c:black);</span></span><br><span class="line"><span class="string">					&amp;:hover&#123;</span></span><br><span class="line"><span class="string">						background: deeppink;</span></span><br><span class="line"><span class="string">					&#125;</span></span><br><span class="line"><span class="string">				   &#125; </span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>../less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			/* 匹配模式，根据传入的不同参数，实现不同的行为 */</span></span><br><span class="line"><span class="string">			.triangle(@_,@w,@c)&#123;</span></span><br><span class="line"><span class="string">				width: 0px;</span></span><br><span class="line"><span class="string">				height: 0px;</span></span><br><span class="line"><span class="string">				border-style: solid;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			/* 下面的所有混合在被使用的时候会自动在内部调用上面这个同名混合 */</span></span><br><span class="line"><span class="string">			.triangle(T,@w,@c)&#123;</span></span><br><span class="line"><span class="string">				border-width: @w;</span></span><br><span class="line"><span class="string">				border-color: @c transparent transparent transparent ;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			.triangle(R,@w,@c)&#123;</span></span><br><span class="line"><span class="string">				border-width: @w;</span></span><br><span class="line"><span class="string">				border-color: transparent @c transparent transparent ;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			.triangle(B,@w,@c)&#123;</span></span><br><span class="line"><span class="string">				border-width: @w;</span></span><br><span class="line"><span class="string">				border-color: transparent transparent @c transparent ;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			.triangle(L,@w,@c)&#123;</span></span><br><span class="line"><span class="string">				border-width: @w;</span></span><br><span class="line"><span class="string">				border-color: transparent transparent transparent @c;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			#wrap&gt;.sjx&#123;</span></span><br><span class="line"><span class="string">				.triangle(B,40px,black);</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>sjx<span class="string">"&gt;&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>../less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<h1 id="arguments变量"><a href="#arguments变量" class="headerlink" title="arguments变量"></a>arguments变量</h1><p>很鸡肋的属性，用之无趣，弃之可惜</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			/* arguments变量表示实参列表*/</span></span><br><span class="line"><span class="string">			.border(@1,@2,@3)&#123;</span></span><br><span class="line"><span class="string">				border: @arguments;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			#wrap&gt;.sjx&#123;</span></span><br><span class="line"><span class="string">				.border(1px,solid,red);</span></span><br><span class="line"><span class="string">				width: 100px;</span></span><br><span class="line"><span class="string">				height: 100px;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>sjx<span class="string">"&gt;&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>../less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<h1 id="继承"><a href="#继承" class="headerlink" title="继承"></a>继承</h1><p>混合它不是公用样式类，而是直接复制一份出来，而继承只是对类添加选择器达到共用的目的，所继承的话是没有代码冗余的，而混合会有代码冗余。以上提到的都是直接引用样式类，都不涉及变量参数的情况。如果要通过参数功能引入变量，输出多样化的样式的话，那继承就无法实现，只能通过混合来实现<br>如果你的代码块中涉及到变量，建议使用混合来创建相同的代码块<br>如果你的代码块不需要专任何变量参数，而且有一个通用类已在文件中存在，那么建议使用 Less 的继承</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//继承</span></span><br><span class="line">.container, .wrap &#123;</span><br><span class="line">    display: flex;</span><br><span class="line">    align-items: center;</span><br><span class="line">    justify-content: center;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//混合</span></span><br><span class="line">.wrap &#123;</span><br><span class="line">    display: flex;</span><br><span class="line">    align-items: center;</span><br><span class="line">    justify-content: center;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">.container &#123;</span><br><span class="line">    display: flex;</span><br><span class="line">    align-items: center;</span><br><span class="line">    justify-content: center;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>less<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			.juzhong&#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			.juzhong:hover&#123;</span></span><br><span class="line"><span class="string">				/* 声明优先级的问题 */</span></span><br><span class="line"><span class="string">				background: red !important;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			*&#123;</span></span><br><span class="line"><span class="string">			    margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			#wrap&#123;</span></span><br><span class="line"><span class="string">				position: relative;</span></span><br><span class="line"><span class="string">				width: 300px;</span></span><br><span class="line"><span class="string">				height: 300px;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				margin: 0 auto;</span></span><br><span class="line"><span class="string">				.inner&#123;</span></span><br><span class="line"><span class="string">					/* all表示继承全部的状态 */</span></span><br><span class="line"><span class="string">					&amp;:extend(.juzhong all);</span></span><br><span class="line"><span class="string">					&amp;:nth-child(1)&#123;</span></span><br><span class="line"><span class="string">						height: 100px;</span></span><br><span class="line"><span class="string">						width: 100px;</span></span><br><span class="line"><span class="string">						background: pink;</span></span><br><span class="line"><span class="string">					&#125;</span></span><br><span class="line"><span class="string">					&amp;:nth-child(2)&#123;</span></span><br><span class="line"><span class="string">						height: 50px;</span></span><br><span class="line"><span class="string">						width: 50px;</span></span><br><span class="line"><span class="string">						background: deeppink;</span></span><br><span class="line"><span class="string">					&#125;</span></span><br><span class="line"><span class="string">				&#125;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				inner1</span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				inner2</span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script src="</span>less/less.min.js<span class="string">" type="</span>text/javascript<span class="string">" charset="</span>utf<span class="number">-8</span><span class="string">"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<h1 id="Less避免编译"><a href="#Less避免编译" class="headerlink" title="Less避免编译"></a>Less避免编译</h1><p>如果你想让Less对某些内容不做编译，可以使用~“xxxxxxxx”,引号中的内容将在编译成的CSS文件中保持原样<br>以上只是Less的一部分介绍，更多可以到Less官方进行详细的查看:<a href="http://lesscss.cn/" target="_blank" rel="noopener">Less</a><br>好了，我的分享就到这里了，谢谢大家</p>

      
      <!-- reward -->
      
      <div id="reward-btn">
        打赏
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>版权声明： </strong s>
              本博客所有文章除特别声明外，均采用 <a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="external nofollow"
                target="_blank">Apache License 2.0</a> 许可协议。转载请注明出处！
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://lockme.gitee.io/2020/05/14/Less-md/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS3/" rel="tag">CSS3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%A2%84%E5%A4%84%E7%90%86%E5%99%A8/" rel="tag">预处理器</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/2020/06/13/Advanced-JS-one-md/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Advanced_JS_one.md
          
        </div>
      </a>
    
    
      <a href="/2020/05/14/CSS-media-md/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">CSS-media.md</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'pmaQYnbUE9O0H1hiYKLiec4R-gzGzoHsz',
        app_key: 'LMujtI79W4vgEQ3Az5IMo50y',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: 'mp',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020
        月下ctrlc
      </li>
      <li>
        
        Powered by
        
        
        <a href="https://hexo.io" target="_blank">Hexo</a> Theme <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
    <aside class="sidebar">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/avatar.jpg" alt="Small Bridge"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/Vue/">Vue</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="http://shenyu-vip.lofter.com" target="_blank" rel="noopener">主题作者相册</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2020/03/18/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>拿钱砸死我吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.png">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.png">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/share.js"></script>


<script src="/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
    onClick: (e) => {
      $('.toc-link').removeClass('is-active-link');
      $(`a[href=${e.target.hash}]`).addClass('is-active-link');
      $(e.target.hash).scrollIntoView();
      return false;
    }
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/js/ayer.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>



<script src="/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>


    
  </div>
</body>

</html>